/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.giant.entities.pos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author david
 */
@Entity
@Table(name = "p_cashbox")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PCashbox.findAll", query = "SELECT p FROM PCashbox p"),
    @NamedQuery(name = "PCashbox.findByIdCashbox", query = "SELECT p FROM PCashbox p WHERE p.idCashbox = :idCashbox"),
    @NamedQuery(name = "PCashbox.findByIdPos", query = "SELECT p FROM PCashbox p WHERE p.idPos = :idPos"),
    @NamedQuery(name = "PCashbox.findByLocation", query = "SELECT p FROM PCashbox p WHERE p.location = :location"),
    @NamedQuery(name = "PCashbox.findByPrefix", query = "SELECT p FROM PCashbox p WHERE p.prefix = :prefix"),
    @NamedQuery(name = "PCashbox.findByStatus", query = "SELECT p FROM PCashbox p WHERE p.status = :status")})
public class PCashbox implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_cashbox")
    private Integer idCashbox;
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_pos")
    private int idPos;
    @Size(max = 50)
    @Column(name = "location")
    private String location;
    @Size(max = 4)
    @Column(name = "prefix")
    private String prefix;
    @Basic(optional = false)
    @NotNull
    @Column(name = "status")
    private boolean status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idCashbox")
    private Collection<PInvoice> pInvoiceCollection;

    public PCashbox() {
    }

    public PCashbox(Integer idCashbox) {
        this.idCashbox = idCashbox;
    }

    public PCashbox(Integer idCashbox, int idPos, boolean status) {
        this.idCashbox = idCashbox;
        this.idPos = idPos;
        this.status = status;
    }

    public Integer getIdCashbox() {
        return idCashbox;
    }

    public void setIdCashbox(Integer idCashbox) {
        this.idCashbox = idCashbox;
    }

    public int getIdPos() {
        return idPos;
    }

    public void setIdPos(int idPos) {
        this.idPos = idPos;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    @XmlTransient
    public Collection<PInvoice> getPInvoiceCollection() {
        return pInvoiceCollection;
    }

    public void setPInvoiceCollection(Collection<PInvoice> pInvoiceCollection) {
        this.pInvoiceCollection = pInvoiceCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCashbox != null ? idCashbox.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PCashbox)) {
            return false;
        }
        PCashbox other = (PCashbox) object;
        if ((this.idCashbox == null && other.idCashbox != null) || (this.idCashbox != null && !this.idCashbox.equals(other.idCashbox))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.giant.entities.PCashbox[ idCashbox=" + idCashbox + " ]";
    }
    
}
